<?php
/*
Sub-Package: URL Shortner Services Class (Additional Services)
Parent-Package: URL Shortener WordPress Plugin Addon
Requires: class.FTShorten.shared, class.googl.php

Copyright Information and Usage
- This class is packaged in the URL Shortener Addon Plugin and can also be downloaded via http://fusedthought.com.
- Permission is granted for re-use of the class in other plugins provided the plugin is released under a similar license as my URL Shortener Plugin.
- This class is not to be packaged as part of a commercial plugin or other any part of a paid download without prior notification to the author.
- If in doubt, email your question to contact@fusedthought.com

Service supported:
- goo.gl - digg - voizule - urli.nl -
*/
require_once(dirname(__FILE__).'/components/class.googl.php');
if (!class_exists('FTShortenExtended')){
	class FTShortenExtended extends FTShortenShared{
		public $service, $url, $name, $apikey, $apiprefix;
		
		public function shorturl(){
			$eurl = $this->url;
			$eservice = $this->service;
			$ename = $this->name;
			$ekey = $this->apikey;
			$eprefix =$this->apiprefix;
				
			switch ($eservice){
				case 'googl':
					$goofx = new googlfx();
					$authtok = $goofx->generateToken($eurl);
					ini_set('user_agent', "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5");
					$apiurl = 'http://goo.gl/api/url';
					$body = array (
						'user' => 'toolbar@google.com',
						'url' => $eurl,
						'auth_token' => $authtok		
					);	
					$result = $this->processxml($apiurl, 'POST', $body);
					ini_restore('user_agent');
					$json = $this->processjson($result);
					$data = $json->short_url;
					break;	
				case 'digg':
					$useragent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5";
					ini_set('user_agent', $useragent);
					$apiurl = "http://services.digg.com/1.0/endpoint/?method=shorturl.create&type=json&url=".$eurl;
					$result = $this->openurl($apiurl, $useragent);
					ini_restore('user_agent');
					$json= $this->processjson($result);
					$data = $json->shorturls[0]->short_url;
					break;
				case 'voizle':
					$data = $this->openurl("http://api.voizle.com/?crawl=no&type=all&property=voizleurl&u=".$eurl); 
					break;
				case 'urlinl':	
					$data = $this->openurl("http://urli.nl/api.php?&format=simple&action=shorturl&url=".$eurl);
					break;	
				default:
					break;		
			}
			return $data;
		}
	
	} //end class
} //end check class

?>